package com.lz.ub.core

import com.lz.ub.UBCOperator
import com.lz.ub.UBCWritable

/**
 * @author You
 * 只响应OK的简单的指令, 常用的只响应成功或者失败没有其他流程的指令
 */
internal class UBCSimple(private val operator: UBCOperator) : UBCWritable {

    var command: String? = null

    fun pushCommand(command: String) {
        this.command = command
        operator.write(command, this)
    }

    override val label: String = "Simple"

    override fun responseOk() {
        command = null
    }

    override fun responseFail() {
        command = null
    }

    override fun close() {
        command = null
    }

    override fun isAvailable(): Boolean = command == null
}